package ui.adapter;

import android.content.Context;
import android.graphics.Color;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fy.fyzf.R;
import com.fy.fyzf.bean.BuildTypeBean;

import java.util.List;

public class BuildAdapter extends BaseQuickAdapter<BuildTypeBean, BaseViewHolder> {

    private Context mContext;
    public BuildAdapter(Context context) {
        super(R.layout.item_build_select);
        mContext = context;
    }

    private int selectPos = 0;
    public void setSelect(int i){
        selectPos = i;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, BuildTypeBean item) {
        if (selectPos == helper.getAdapterPosition()) {
            helper.itemView.setBackground(mContext.getResources().getDrawable(R.drawable.theme_back_round3));
            helper.setTextColor(R.id.tv_name, Color.WHITE);
            helper.setTextColor(R.id.tv_count, Color.WHITE);
        } else {
            helper.itemView.setBackground(mContext.getResources().getDrawable(R.drawable.select_false));
            helper.setTextColor(R.id.tv_name, Color.parseColor("#353433"));
            helper.setTextColor(R.id.tv_count, Color.parseColor("#9B9B99"));
        }

        helper.setText(R.id.tv_name, item.getName()).setText(R.id.tv_count, item.getCount());
    }
}
